import fetch from '@/utils/fetch'

export function apiGetRoleList(listQuery) {
  return fetch({
    url: '/api/v1/role/list',
    method: 'get',
    params: listQuery
  })
}

export function apiGetRoleById(id) {
  return fetch({
    url: '/api/v1/role',
    method: 'get',
    params: {
      roleId: id
    }
  })
}

export function apiAddRole(roleDto) {
  return fetch({
    url: '/api/v1/role',
    method: 'post',
    data: roleDto
  })
}

export function apiUpdRole(roleDto) {
  return fetch({
    url: '/api/v1/role',
    method: 'put',
    data: roleDto
  })
}

export function apiDelRole(id) {
  return fetch({
    url: '/api/v1/role',
    method: 'delete',
    params: {
      roleId: id
    }
  })
}

export function apiGetRolePerms(roleId, type) {
  return fetch({
    url: '/api/v1/role/detail',
    method: 'get',
    params: {
      roleId: roleId,
      type: type
    }
  })
}

export function apiUpdRolePerms(data) {
  return fetch({
    url: '/api/v1/role/perm',
    method: 'put',
    data: data
  })
}
